<div class="dvModuleContainer">
	<form id="frm" action="<?=fwUrl("doupload")?>" method="post" enctype="multipart/form-data" target="_self">
	
	<input type="hidden" id="indexObj" name="indexObj" />
	<input type="hidden" id="objName" name="objName" />
	<input type="hidden" id="returnUrl" name="returnUrl" value="<?=curPageURL()?>" />
	
	<?
	
		$u_agent = $_SERVER['HTTP_USER_AGENT'];
		$browser = "";	
		
		if(preg_match('/MSIE/i',$u_agent)) {
			$browser = "IE";
		}elseif(preg_match('/Firefox/i',$u_agent)){
			$browser = "FF";
		}
		
		$arr = array(
			"contact.jpg"
			);
		for($i=0; $i < count($arr); $i++ ) {
		
		$info = getimagesize("data/$arr[$i]");
			
		$w = $info[0];
		$h = $info[1];
		
		
		
		if($w > 400) {			
			$w = 400;
			$h = 300;
		}
	?>
	<div class="thump">
		<div class="sub-thump shadowMe2">		
			<?
				$name = explode('.', $arr[$i]);
				if($name[1] == "m4v") {				
					if($browser == "IE" || $browser == "FF") {
		
					} else {				
			?>		
					<video width="400" src="data/<?=$arr[$i]?>"></video>
			<?
					}
				} else {		
			?>		
			<a class="fancyMe" href="data/<?=$arr[$i]?>"><img src="data/<?=$arr[$i]?>" width="<?=$w?>" height="<?=$h?>"/></a>
			<?
				}
			?>
	
			<div class="file-detail">
				<div>
					<? 
					if($name[1] == "m4v") {
						echo "<b>VDO</b><br>";
					}								
					?>
					
					File size: <?=filesize("data/$arr[$i]") ?> bytes <br>
					File name: <?=$arr[$i]?> <br>
					
					<? 
					if($name[1] == "m4v") {
					
					} else {						
						echo $info[3];
					}								
					?>
					
				</div>
			</div>		
		</div>	
		<div class="form">
			<input id="fake_<?=$i?>" name="fake_<?=$i?>" type="text" class="inputBox" placeholder="File Name" />
			<input id="btn_<?=$i?>" name="btn_<?=$i?>" type="button" class="" value="Choose File" />
			<div class="upload" onclick="do__upload('<?=$i?>','<?=$arr[$i]?>')"></div>
			<input id="file_<?=$i?>" name="file_<?=$i?>" type="file">
		</div>
	</div>
	
	<?
		}
	?>
	
	</form>
</div>
<script language="JavaScript" type="text/javascript">
	$(document).ready(function(){
		$(".fancyMe").fancybox({
			'transitionIn'	: 'none', 
			'transitionOut'	: 'none'
		});
		
		$("input[type=file]").change(function(){
			name = $(this).prop("name");			
			$("#fake_" + name.split("_")[1]).val($(this).val().split('\\').pop());
			
			console.log("#" + name.split("_")[1]);
		});
		
		if($.browser.safari || $.browser.webkit) {
			
		} else {
					
		}
		
	});
	
	function do__upload(id, name){
		
		$("#indexObj").val(id);
		$("#objName").val(name);
		
		if($("#fake_" + id).val() == ""){
			alert("Please choose file");
			return;
		}
		
		$("#frm").submit();	
	}
	
</script>